﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AdRotator.Common
{
    /// <summary>
    /// Defines an ad provider.
    /// </summary>
    /// <remarks>
    /// This interface doesn't specify the ad creation method as that can differ base on whether or not the ad
    ///     provider manipulates the visual tree or not when creating an ad. See <see cref="IAdProviderManipulatingVisualTree"/>
    ///     and <see cref="IAdProviderNotManipulatingVisualTree"/>
    /// The interface is marked internal because AdProviderBase needs to be implemented for all ad types in order for
    ///     XML serialization to work (interfaces can't be serialized, whereas abstract classes - even if it's tricky - can
    /// </remarks>
    internal interface IAdProvider
    {
        /// <summary>
        /// Gets or sets whether this ad provider should be used as default for the current culture
        /// </summary>
        bool IsDefault { get; set; }

        /// <summary>
        /// Gets or sets the probability that this ad provider will be used
        /// </summary>
        double Probability { get; set; }

        /// <summary>
        /// Gets or sets whether the ad provider is running in test mode.
        ///     Not all ad providers support test modes: for those that don't, changing this flag won't
        ///     result in different behaviour
        /// </summary>
        bool IsTest { get; set; }

        /// <summary>
        /// Gets whether the ad provider is valid. An ad provider is considered valid if all required properties
        ///     (e.g. app IDs, publisher IDs etc) are all set as required in the concrete class
        /// </summary>
        bool IsValid { get; }        

        /// <summary>
        /// Fires the Log event
        /// </summary>
        event LogHandler Log;

        /// <summary>
        /// Fired if the ad is not loaded succesfully
        /// </summary>
        event EventHandler AdLoadingError;

        /// <summary>
        /// Invoked when the ad is shown. Register various even handlers for the ad at this point
        /// </summary>
        void Initialize();

        /// <summary>
        /// Invoked when the ad is hidden. Unregister various event handlers for the ad at this point
        /// </summary>
        void Deinitialize();
    }

    public delegate void LogHandler(string message);
}
